package com.aduerr.v1shouyin.mvp.activity;

import android.graphics.Color;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.aduerr.v1shouyin.R;
import com.aduerr.v1shouyin.entity.*;
import com.aduerr.v1shouyin.http.APIRetrofit;
import com.aduerr.v1shouyin.http.RXRequest;
import com.aduerr.v1shouyin.print.PrinterWrapper;
import com.aduerr.v1shouyin.unioncard.BaseUnionActivity;
import com.aduerr.v1shouyin.util.SharedPreferencesUtils;
import com.aduerr.v1shouyin.util.ToastUtils;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

import java.util.HashMap;


public class CardDetailNewActivity extends BaseUnionActivity {


    private static int defalutBackIconResID;

    static {
        defalutBackIconResID = R.drawable.btn_back;
    }

    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.card_num)
    TextView tvFinishHexiao;
    //wx
    @BindView(R.id.ll_wx)
    LinearLayout llWx;
    @BindView(R.id.card_name)
    TextView tvWxCardName;
    @BindView(R.id.tv_type)
    TextView tvWxType;
    @BindView(R.id.card_time)
    TextView tvWxCardTime;
    //团购券 门票
    @BindView(R.id.ll_tuangou)
    LinearLayout llTuanGou;
    @BindView(R.id.tuangou_name)
    TextView tvTuanGouName;
    @BindView(R.id.tv_tuangou_type)
    TextView tvTuanGouType;
    @BindView(R.id.order_money)
    TextView tvTuanGouMoney;
    @BindView(R.id.order_state)
    TextView tvTuanGouState;
    @BindView(R.id.order_time)
    TextView tvTuanGouOderTime;
    @BindView(R.id.tv_tuangou_num)
    TextView tvTuGouOrderID;
    @BindView(R.id.ll_menpiao_order)
    RelativeLayout llMenPiaoOrder;
    //酒店
    @BindView(R.id.ll_jiudian)
    LinearLayout llJiuDian;
    @BindView(R.id.jiudian_name)
    TextView tvJiuDianName;
    @BindView(R.id.jiudian_type)
    TextView tvJiudianType;
    @BindView(R.id.jiudian_money)
    TextView tvJiuDianMoney;
    @BindView(R.id.jiudian_state)
    TextView tvJiuDianState;
    @BindView(R.id.order_jiudian_time)
    TextView tvJiudianOrderTime;
    @BindView(R.id.jiudian_contract)
    TextView tvJiudianContract;
    @BindView(R.id.jiudian_ordernum)
    TextView tvJiuDianOrderNum;
    //礼品
    @BindView(R.id.ll_lipin)
    LinearLayout llLiPin;
    @BindView(R.id.order_name_lipin)
    TextView tvLiPinName;
    @BindView(R.id.lipin_name)
    TextView tvLiPinUserName;
    @BindView(R.id.lipin_time)
    TextView tvLiPinTime;
    @BindView(R.id.lipin_jifen_state)
    TextView tvLiPinJifen;
    //口碑
    @BindView(R.id.ll_koubei)
    LinearLayout llKouBei;
    @BindView(R.id.order_name_koubei)
    TextView tvKouBeiName;
    @BindView(R.id.order_type_koubei)
    TextView tvKouBeiType;
    @BindView(R.id.tv_koubei_realmoney)
    TextView tvKouBeiRealMoney;
    @BindView(R.id.koubei_nowmoney)
    TextView tvKouBeiNowMoney;
    @BindView(R.id.koubei_shishou)
    TextView tvKouBeiShiShou;
    //关于
    @BindView(R.id.rl_about)
    RelativeLayout rlAbout;
    @BindView(R.id.about_content)
    TextView tvAboutContent;
    @BindView(R.id.tv_card_num)
    TextView tvCardNum;
    @BindView(R.id.hexiao_person)
    TextView tvHeXiaoP;
    @BindView(R.id.hexiao_time)
    TextView tvHexiaoTime;
    @BindView(R.id.rl_state)
    RelativeLayout rlState;
    @BindView(R.id.hexiao_state)
    TextView tvHeXiaoState;
    @BindView(R.id.tv_toolbar_title)
    TextView tvToolbarTitle;
    String type;
    //21  34  8
    OtherCardEntity otherCardEntity;

    //koubei
//    KouBeiUseEntity kouBeiUseEntity;

    //卡券码
//    String erWeiMaResult;
    WriteOffListEntity.DataBean writeOffDataBean;
    //WX
    KaQuanXiangQingEntity.DataBean.ListBean kaquanxiangqingEntity;
    @BindView(R.id.ll_add)
    LinearLayout llAdd;
    @BindView(R.id.rl_needpay)
    RelativeLayout rl_needpay;
    @BindView(R.id.tv_jine)
    TextView tvNeedPay;
    @BindView(R.id.ll_koubei_about)
    LinearLayout llKouBeiAbout;
    //打印按钮
    @BindView(R.id.btn_topay)
    Button btnToPay;
    int typeNum;
    BarTicketEntity.DataBean listBean;

    KouBeiHeXiaoListEntity.DataBean.ListBean kouDataBean;
    private String[] content = new String[20];
    String  shopName  = "";

    String cardMemberName = "";//会员次卡用的会员名
    String cardMemberPhone = "";//会员次卡用会员电话
    String cardSurpluscount = "";//会员次卡剩余次数

    @Override
    protected int getLayoutId() {
        return R.layout.activity_card_detail_success;
    }

    @Override
    protected void initBase() {
        super.initView();
        ButterKnife.bind(this);
        initToolbarWithBack(0);
        initDate();
    }

    public void initToolbarWithBack(int backResId) {
        tvToolbarTitle.setText("卡券详情");
        if(mToolbar != null) {
            int rid = backResId == 0 ? defalutBackIconResID : backResId;
            mToolbar.setNavigationIcon(rid);
            mToolbar.setNavigationOnClickListener(v -> finish());
        }
    }

    private void initDate() {
        type = getIntent().getStringExtra("type");
        if(CardType.WX.name().equals(type)) {
            llKouBeiAbout.setVisibility(View.GONE);
            llWx.setVisibility(View.VISIBLE);
            llJiuDian.setVisibility(View.GONE);
            llLiPin.setVisibility(View.GONE);
            llKouBei.setVisibility(View.GONE);
            llTuanGou.setVisibility(View.GONE);
            kaquanxiangqingEntity =
                    (KaQuanXiangQingEntity.DataBean.ListBean) getIntent().getSerializableExtra("Data");
            tvWxCardName.setText(kaquanxiangqingEntity.getName());
            tvWxCardTime.setText(kaquanxiangqingEntity.getBegintime().split(" ")[0] +
                    "~" + kaquanxiangqingEntity.getEndtime().split(" ")[0]);
            shopName = (String)kaquanxiangqingEntity.getShopname();
            content[9] = shopName;
            if("0".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("优惠券");
                tvWxType.setBackgroundColor(getResources().getColor(R.color.y_color));
                tvAboutContent.setText(kaquanxiangqingEntity.getUsershuoming());
                tvCardNum.setText(kaquanxiangqingEntity.getTicketCode());
                tvHeXiaoP.setText(kaquanxiangqingEntity.getSiteusername());
                tvHexiaoTime.setText(kaquanxiangqingEntity.getUsetime());
                rl_needpay.setVisibility(View.GONE);
            }
            if("1".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("抵用券");
                tvWxType.setBackgroundColor(getResources().getColor(R.color.d_color));
                tvAboutContent.setText(kaquanxiangqingEntity.getUsershuoming());
                tvCardNum.setText(kaquanxiangqingEntity.getTicketCode());
                tvHeXiaoP.setText(kaquanxiangqingEntity.getSiteusername());
                tvHexiaoTime.setText(kaquanxiangqingEntity.getUsetime());
                rl_needpay.setVisibility(View.GONE);
            }
            if("2".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("折扣券");
                tvWxType.setBackgroundColor(getResources().getColor(R.color.z_color));
                rl_needpay.setVisibility(View.GONE);
                tvAboutContent.setText(kaquanxiangqingEntity.getUsershuoming());

                tvCardNum.setText(kaquanxiangqingEntity.getTicketCode());
                tvHeXiaoP.setText(kaquanxiangqingEntity.getSiteusername());
                tvHexiaoTime.setText(kaquanxiangqingEntity.getUsetime());
            }
            if("3".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("代金券");
                tvWxType.setBackgroundColor(getResources().getColor(R.color.d_color));
                rl_needpay.setVisibility(View.GONE);
                tvNeedPay.setText(kaquanxiangqingEntity.getMinmoney() + "元");
                tvAboutContent.setText(kaquanxiangqingEntity.getUsershuoming());
                tvCardNum.setText(kaquanxiangqingEntity.getTicketCode());
                tvHeXiaoP.setText(kaquanxiangqingEntity.getSiteusername());
                tvHexiaoTime.setText(kaquanxiangqingEntity.getUsetime());
            }
            if("4".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("礼品券");
                tvWxType.setBackgroundColor(getResources().getColor(R.color.l_color));
                tvAboutContent.setText(kaquanxiangqingEntity.getUsershuoming());
                tvCardNum.setText(kaquanxiangqingEntity.getTicketCode());
                tvHeXiaoP.setText(kaquanxiangqingEntity.getSiteusername());
                tvHexiaoTime.setText(kaquanxiangqingEntity.getUsetime());
                rl_needpay.setVisibility(View.GONE);
            }
            if("5".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("团购券");
                tvWxType.setBackgroundColor(getResources().getColor(R.color.t_color));
                tvAboutContent.setText(kaquanxiangqingEntity.getUsershuoming());
                tvCardNum.setText(kaquanxiangqingEntity.getTicketCode());
                tvHeXiaoP.setText(kaquanxiangqingEntity.getSiteusername());
                tvHexiaoTime.setText(kaquanxiangqingEntity.getUsetime());
                rl_needpay.setVisibility(View.GONE);
            }

            if("6".equals(kaquanxiangqingEntity.getType())) {
                tvWxType.setText("次卡");
                tvWxType.setBackgroundColor(Color.parseColor("#65B45B"));
                tvAboutContent.setText(kaquanxiangqingEntity.getUsershuoming());
                tvCardNum.setText(kaquanxiangqingEntity.getTicketCode());
                tvHeXiaoP.setText(kaquanxiangqingEntity.getSiteusername());
                tvHexiaoTime.setText(kaquanxiangqingEntity.getUsetime());
                btnToPay.setVisibility(View.VISIBLE);
                rl_needpay.setVisibility(View.GONE);

                cardMemberName = kaquanxiangqingEntity.getMemberName();
                cardMemberPhone = kaquanxiangqingEntity.getMemberPhone();
                cardSurpluscount = kaquanxiangqingEntity.getSurpluscount();
            }


        }
        if(CardType.JIUDIAN.name().equals(type)) {
            llKouBeiAbout.setVisibility(View.GONE);
            typeNum = getIntent().getIntExtra("typenum", -1);
            llWx.setVisibility(View.GONE);
            llJiuDian.setVisibility(View.VISIBLE);
            llLiPin.setVisibility(View.GONE);
            llKouBei.setVisibility(View.GONE);
            llTuanGou.setVisibility(View.GONE);
            listBean = (BarTicketEntity.DataBean) getIntent().getSerializableExtra(
                    "Data");
            rl_needpay.setVisibility(View.GONE);
            rlAbout.setVisibility(View.GONE);
            rlState.setVisibility(View.VISIBLE);
            getIndustryInfo();

            //少一个联系电话的字段
//            tvJiudianContract.setText(industryEntity.getData().getPhone());
        }
        if(CardType.KOUBEI.name().equals(type)) {
            llKouBeiAbout.setVisibility(View.VISIBLE);
            llWx.setVisibility(View.GONE);
            llJiuDian.setVisibility(View.GONE);
            llLiPin.setVisibility(View.GONE);
            llKouBei.setVisibility(View.VISIBLE);
            llTuanGou.setVisibility(View.GONE);
            rlAbout.setVisibility(View.VISIBLE);
            kouDataBean =
                    (KouBeiHeXiaoListEntity.DataBean.ListBean) getIntent().getSerializableExtra("Data");
            tvKouBeiType.setText("口碑券");
//    kouBeiUseEntity = (KouBeiUseEntity) getIntent().getSerializableExtra("Data");
            getKouBeiDetail();
            rl_needpay.setVisibility(View.GONE);
        }
        if(CardType.LIPIN.name().equals(type)) {
            llKouBeiAbout.setVisibility(View.GONE);
            llWx.setVisibility(View.GONE);
            llJiuDian.setVisibility(View.GONE);
            llLiPin.setVisibility(View.VISIBLE);
            llKouBei.setVisibility(View.GONE);
            llTuanGou.setVisibility(View.GONE);
            writeOffDataBean =
                    (WriteOffListEntity.DataBean) getIntent().getSerializableExtra(
                            "Data");
//            otherCardEntity = (OtherCardEntity) getIntent().getSerializableExtra
// ("Data");
            tvLiPinName.setText(writeOffDataBean.getName());
//            tvLiPinTime.setText(writeOffDataBean. + "~" + otherCardEntity.getData()
// .getEndtime());
//            tvLiPinJifen.setText();
            tvLiPinUserName.setText(writeOffDataBean.getNickName());
            rlAbout.setVisibility(View.VISIBLE);
            tvCardNum.setText(writeOffDataBean.getSnCode());
//            tvHeXiaoP.setText(writeOffDataBean.);
            tvHexiaoTime.setText(writeOffDataBean.getUseTime());
            rl_needpay.setVisibility(View.GONE);

            getMemberGiftDetail(writeOffDataBean.getSnCode());

        }
        //门票和团购
        if(CardType.MENPIAOANDTUANGOU.name().equals(type)) {
            llKouBeiAbout.setVisibility(View.GONE);
            typeNum = getIntent().getIntExtra("typenum", -1);
            if(typeNum == 0) {
                llMenPiaoOrder.setVisibility(View.GONE);
                tvTuanGouType.setText("门票");
                tvTuanGouType.setBackgroundColor(getResources().getColor(R.color.t_color));
            } else {
                tvTuanGouType.setText("团购券");
                tvTuanGouType.setBackgroundColor(getResources().getColor(R.color.t_color));
            }

            llWx.setVisibility(View.GONE);
            llJiuDian.setVisibility(View.GONE);
            llLiPin.setVisibility(View.GONE);
            llKouBei.setVisibility(View.GONE);
            llTuanGou.setVisibility(View.VISIBLE);
            listBean = (BarTicketEntity.DataBean) getIntent().getSerializableExtra(
                    "Data");
            rlAbout.setVisibility(View.VISIBLE);
            rlState.setVisibility(View.VISIBLE);
            rl_needpay.setVisibility(View.GONE);

            getIndustryInfo();
        }
    }

    @OnClick({R.id.btn_topay})
    public void OnViewClicked(View view) {
        switch(view.getId()) {
            case R.id.btn_topay:
                content[0] = "卡券凭据";
                if(CardType.WX.name().equals(type)) {
                    content[1] = tvWxCardName.getText().toString();
                    content[2] = tvWxType.getText().toString();
                    content[3] = tvWxCardTime.getText().toString();
                    content[4] = tvCardNum.getText().toString();
                    content[5] = tvHexiaoTime.getText().toString();
                    content[6] = tvHeXiaoP.getText().toString();
                    content[7] = tvAboutContent.getText().toString();

                    content[10] =cardMemberName;
                    content[11] =cardMemberPhone;
                    content[12] =cardSurpluscount;


                } else if(CardType.JIUDIAN.name().equals(type)) {
                    content[1] = tvJiuDianOrderNum.getText().toString();
                    content[2] = tvJiuDianMoney.getText().toString();
                    content[3] = tvJiuDianState.getText().toString();
                    content[4] = tvJiudianContract.getText().toString();
                    content[5] = tvJiudianOrderTime.getText().toString();
                    content[6] = tvHexiaoTime.getText().toString();
                    content[7] = tvHeXiaoP.getText().toString();
                } else if(CardType.KOUBEI.name().equals(type)) {
                    content[1] = tvKouBeiName.getText().toString();
                    content[2] = tvKouBeiRealMoney.getText().toString();
                    content[3] = tvKouBeiNowMoney.getText().toString();
                    content[4] = tvKouBeiShiShou.getText().toString();
                    content[5] = tvCardNum.getText().toString();
                    content[6] = tvHexiaoTime.getText().toString();
                    content[7] = tvHeXiaoP.getText().toString();
                } else if(CardType.LIPIN.name().equals(type)) {
                    content[1] = tvLiPinName.getText().toString();
                    content[2] = tvLiPinTime.getText().toString();
                    content[3] = tvLiPinJifen.getText().toString();
                    content[4] = tvLiPinUserName.getText().toString();
                    content[5] = tvCardNum.getText().toString();
                    content[6] = tvHexiaoTime.getText().toString();
                    content[7] = tvHeXiaoP.getText().toString();
                } else if(CardType.MENPIAOANDTUANGOU.name().equals(type)) {
                    content[1] = tvTuanGouName.getText().toString();
                    content[2] = tvTuGouOrderID.getText().toString();
                    content[3] = tvTuanGouMoney.getText().toString();
                    content[4] = tvTuanGouState.getText().toString();
                    content[5] = tvTuanGouOderTime.getText().toString();
                    content[6] = tvCardNum.getText().toString();
                    content[7] = tvHexiaoTime.getText().toString();
                    content[8] = tvHeXiaoP.getText().toString();
                }
                cantoprintlastorder();
                break;
        }
    }


    public void getKouBeiDetail() {
        HashMap<String, String> addParams = new HashMap<>();
        addParams.put("TicketID", kouDataBean.getTicketCode());//86008032893055438199
        // test
        APIRetrofit.getAPIService().getKouBeiquanDetail(RXRequest.getXingPosParams(addParams, this))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(kouBeiTicktEntity -> {
                    int success = kouBeiTicktEntity.getSuccess();
                    if(success == 1) {
                        //跳转到卡券信息的详情界面
                        tvKouBeiName.setText(kouBeiTicktEntity.getData().getItemName());
                        tvKouBeiRealMoney.setText(kouBeiTicktEntity.getData().getOriginalPrice() + "元");
                        tvKouBeiNowMoney.setText(kouBeiTicktEntity.getData().getCurrentPrice() + "元");
                        tvKouBeiShiShou.setText(kouBeiTicktEntity.getData().getCurrentPrice() + "元");
                        tvAboutContent.setText(kouDataBean.getDescription());
                        tvCardNum.setText(kouBeiTicktEntity.getData().getTicketCode());
                        tvHeXiaoP.setText(kouDataBean.getSiteusername());
                        tvHexiaoTime.setText(kouDataBean.getUsetime());
                    } else {
                        ToastUtils.showToast(CardDetailNewActivity.this,
                                kouBeiTicktEntity.getErrMsg() + "");
                    }
                }, throwable -> {
                });
    }

    public void getIndustryInfo() {
        HashMap<String, String> addParams = new HashMap<>();
        addParams.put("type", typeNum + "");
        addParams.put("id", listBean.getID() + "");//86008032893055438199  test
        APIRetrofit.getAPIService().getIndystryInfo(RXRequest.getXingPosParams(addParams, this))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(industryEntity -> {
//                    ld.close();
                    int success = industryEntity.getSuccess();
                    if(success == 1) {
                        if(typeNum == 1) {
                            tvJiudianContract.setText(industryEntity.getData().getTel());
                            tvJiudianOrderTime.setText(industryEntity.getData().getCreateTime());
                            tvCardNum.setText(industryEntity.getData().getOrderID());
                            tvHeXiaoP.setText(industryEntity.getData().getLinkMan());
                            tvHexiaoTime.setText(industryEntity.getData().getUsedTime());
                            tvJiudianType.setText("酒店");
                            tvJiuDianName.setText(industryEntity.getData().getTitle());
                            tvJiuDianMoney.setText(industryEntity.getData().getOrderMoney() + "元");
                            tvJiudianOrderTime.setText(industryEntity.getData().getCreateTime());
//                            tvJiuDianState.setText(industryEntity.getData()
// .getOrderState());
                            tvJiuDianOrderNum.setText(industryEntity.getData().getOrderID());
                            tvAboutContent.setText(industryEntity.getData().getExplain());
                            if("0".equals(industryEntity.getData().getOrderState())) {
                                tvJiuDianState.setText("未付款");
                            } else if("1".equals(industryEntity.getData().getOrderState())) {
                                tvJiuDianState.setText("已支付");
                            } else if("2".equals(industryEntity.getData().getOrderState())) {
                                tvJiuDianState.setText("已到店");
                            } else if("3".equals(industryEntity.getData().getOrderState())) {
                                tvJiuDianState.setText("已离店");
                            } else {
                                tvJiuDianState.setText("已取消");
                            }
                        } else if(typeNum == 0) {

                            tvTuanGouOderTime.setText(industryEntity.getData().getCreateTime());
                            tvCardNum.setText(industryEntity.getData().getOrderID());
                            tvHeXiaoP.setText(industryEntity.getData().getLinkMan());
                            tvHexiaoTime.setText(industryEntity.getData().getUsedTime());
                            tvTuanGouName.setText(industryEntity.getData().getTitle());
                            tvTuGouOrderID.setText(industryEntity.getData().getOrderID());
                            tvTuanGouMoney.setText(industryEntity.getData().getOrderMoney() + "元");
                            tvAboutContent.setText(industryEntity.getData().getExplain());
                            if(0 == industryEntity.getData().getState()) {
                                tvTuanGouState.setText("待支付");
                            } else if(1 == industryEntity.getData().getState()) {
                                tvTuanGouState.setText("已支付");
                            } else if(2 == industryEntity.getData().getState()) {
                                tvTuanGouState.setText("已支付");
                            } else if(3 == industryEntity.getData().getState()) {
                                tvTuanGouState.setText("已核销");
                            } else {
                                tvTuanGouState.setText("已取消");
                            }
                        } else if(typeNum == 2) {
                            tvTuanGouOderTime.setText(industryEntity.getData().getCreateTime());
                            tvCardNum.setText(industryEntity.getData().getOrderID());
                            tvHeXiaoP.setText(industryEntity.getData().getLinkMan());
                            tvHexiaoTime.setText(industryEntity.getData().getUsedTime());
                            tvTuanGouName.setText(industryEntity.getData().getTitle());
                            tvTuGouOrderID.setText(industryEntity.getData().getOrderID());
                            tvTuanGouMoney.setText(industryEntity.getData().getOrderMoney() + "元");
                            tvAboutContent.setText(industryEntity.getData().getExplain());
                            if(0 == industryEntity.getData().getTgState()) {
                                tvTuanGouState.setText("未支付");
                            } else if(1 == industryEntity.getData().getTgState()) {
                                tvTuanGouState.setText("已支付");
                            } else if(2 == industryEntity.getData().getTgState()) {
                                tvTuanGouState.setText("已发货");
                            } else if(3 == industryEntity.getData().getTgState()) {
                                tvTuanGouState.setText("已完成");
                            } else if(4 == industryEntity.getData().getTgState()) {
                                tvTuanGouState.setText("已失效");
                            } else if(5 == industryEntity.getData().getTgState()) {
                                tvTuanGouState.setText("申请退款");
                            } else {
                                tvTuanGouState.setText("已退款");
                            }
                        }


                    } else {
                        ToastUtils.showToast(CardDetailNewActivity.this,
                                industryEntity.getErrMsg() + "");
                    }
                }, throwable -> {
//                    ld.close();
                });
    }


    public void getMemberGiftDetail(String id) {
        HashMap<String, String> addParams = new HashMap<>();
        addParams.put("code", id);
        APIRetrofit.getAPIService().getOtherCardDetail(RXRequest.getXingPosParams(addParams, this))
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(giftDetailEntity -> {
                    if(giftDetailEntity.getSuccess() == 1) {
                        tvLiPinJifen.setText(giftDetailEntity.getData().getNeedIntegral() + "积分");
                        tvHeXiaoP.setText(giftDetailEntity.getData().getUserName());
                    } else {
                        //donothing  if  erro !=1
                        ToastUtils.showToast(this, giftDetailEntity.getErrMsg() + "");
                    }
                }, throwable -> {

                });


    }


    //判断是否可以打印
    private void cantoprintlastorder() {
        int printpage = (int) SharedPreferencesUtils.getParam(this, "printpage", 1);
        if(printpage == 0) {
            ToastUtils.showToast(this, "打印张数设置为不打印,请先设置打印张数!!");
            return;
        }
        if(content != null && content.length > 0) {
            PrinterWrapper.printHxDetail(printpage,false,content);
        }
    }

}
